/**
 * Created by bjh on 2017/11/10.
 *
 */

import GM from "g2-mobile";

const cfg = {
    point: {
        lineWidth: 1,
        fill: '#999',
        radius: 4
    },
    hollowPoint: {
        fill: '#fff',
        lineWidth: 1,
        stroke: '#999',
        radius: 3
    },
    interval: {
        lineWidth: 0,
        fill: '#999',
        fillOpacity: 0.85
    },
    strokeInterval: {
        lineWidth: 1,
        stroke: '#fff'
    },
    pie: {
        lineWidth: 1,
        stroke: '#fff'
    },
    hollowInterval: {
        fill: '#fff',
        stroke: '#999',
        fillOpacity: 0,
        lineWidth: 1
    },
    area: {
        lineWidth: 0,
        fill: '#999',
        fillOpacity: 0.6
    },
    polygon: {
        lineWidth: 0,
        fill: '#999',
        fillOpacity: 1
    },
    hollowPolygon: {
        fill: '#fff',
        stroke: '#999',
        fillOpacity: 0,
        lineWidth: 1
    },
    strokePolygon: {
        fill: '#999',
        stroke: '#efefef',
        fillOpacity: 1
    },
    hollowArea: {
        fill: '#fff',
        stroke: '#999',
        fillOpacity: 0,
        lineWidth: 1
    },
    line: {
        stroke: '#999',
        lineWidth: 1,
        fill: null
    }
};


class ChartStyle {
    constructor(cfg){
        this.cfg = cfg
        GM.style(cfg);
    }

    addStyle(style){
        this.cfg = Object.assign(this.cfg, style);
        GM.style(this.cfg);
    }

    removeStyle(style){
        const keys = Object.keys(style);
        keys.map( item => {
            this.cfg[item] = null;
        })
        GM.style(this.cfg);
    }
}

export default new ChartStyle(cfg)